package cn.middle.remote.message;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import cn.middle.remote.util.ConversionUtil;

public class LoginResultSignal extends BaseSignal {
	
	private int code;
	
	private String message;
	
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public LoginResultSignal() {
		super(SignalHelper.LOGIN_RESULT);
	}

	@Override
	public byte[] toData() {
		ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
		DataOutputStream out = new DataOutputStream(bos);
		try {
			out.writeInt(code);
			out.write(ConversionUtil.writeStringBytes(getMessage()));
			out.flush();
			return bos.toByteArray();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

}
